package com.apes.fico.engine.model;

import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @program: apestech
 * @description: 要素组
 * @author: Chengxm
 * @create: 2019-01-24 15:42
 **/
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = ElementGroupItem.CONST_TABLE_NAME)
public class ElementGroupItem implements ApesBean {
    public final static String CONST_TABLE_NAME = "fin_element_group_item";
    @Id
    @Column(name = "id", length = 8)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "要素组明细")
    @Comment("编码")
    private String id;

    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "element_group_id", referencedColumnName = "id")
    @Comment("要素组")
    private ElementGroup elementGroup;

    @Comment("要素")
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "element_id", referencedColumnName = "id", nullable = false)
    private Element element;

    @Column(name = "priority", nullable = false)
    @Comment("优先级")
    private int priority;


}
